tools/xenstore: fix node accounting after failed node creation
authorJuergen Gross <jgross@suse.com>
Thu, 11 Jun 2020 14:12:39 +0000 (16:12 +0200)
committerHans van Kranenburg <hans@knorrie.org>
Tue, 15 Dec 2020 11:28:46 +0000 (12:28 +0100)
commitc9c5a2cde8f551031d551a1da4a485ee1dffb418
treee10a16c63ce0345712625f28c08dc8f0db6db105
parentdae912548d28bf10ec24365579a3922f185f6c94
tools/xenstore: fix node accounting after failed node creation

When a node creation fails the number of nodes of the domain should be
the same as before the failed node creation. In case of failure when
trying to create a node requiring to create one or more intermediate
nodes as well (e.g. when /a/b/c/d is to be created, but /a/b isn't
existing yet) it might happen that the number of nodes of the creating
domain is not reset to the value it had before.

So move the quota accounting out of construct_node() and into the node
write loop in create_node() in order to be able to undo the accounting
in case of an error in the intermediate node destructor.

This is part of XSA-115.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Paul Durrant <paul@xen.org>
Acked-by: Julien Grall <jgrall@amazon.com>
tools/xenstore/xenstored_core.c